//
//  RouteRemarkView.m
//  DigiOps
//
//  Created by app on 2018/7/17.
//  Copyright © 2018年 俞渊华. All rights reserved.
//

#import "RouteRemarkView.h"
@interface RouteRemarkView()
@property(nonatomic,strong) UILabel* remarkLabel;
//@property(nonatomic,strong) UIButton* remarkLabel1;

@end
@implementation RouteRemarkView

-(instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        self.backgroundColor = [UIColor clearColor];
        //        self.remarkLabel = [[UILabel alloc]init];
        self.remarkLabel1 = [[UIButton alloc]init];
        
        //        self.remarkLabel.textColor = [UIColor xm_colorFromRGB:0x858C96];
        //        self.remarkLabel.textColor=[UIColor blueColor];
        [self.remarkLabel1 setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
        if ([MySingleton sharedMySingleton].finished) {//已完成异常备注灰色
            [self.remarkLabel1 setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        }
        [self.remarkLabel1.titleLabel setFont:[UIFont xm_font:15.0]];
        if (IS_IPHONE_5) {
            [self.remarkLabel1.titleLabel setFont:[UIFont xm_font:13.0]];
            
        }
        //        self.remarkLabel.font = [UIFont xm_font:15.0];
        self.remarkLabel1.layer.cornerRadius=2;
        self.remarkLabel1.backgroundColor =[UIColor whiteColor];
        //        self.remarkLabel1.layer.borderColor=[UIColor darkGrayColor].CGColor;
        self.remarkLabel1.layer.borderColor=[UIColor clearColor].CGColor;
        self.remarkLabel1.layer.borderWidth=0.3;
        [self.remarkLabel1 addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.remarkLabel1];
    }
    return self;
}
-(void)back{
    if (self.block) {
        self.block();
    }
}
-(void)setLine:(LineDetail *)line{
    _line = line;
    //        self.taskLabel.text = @"巡逻任务";
    self.remarkLabel.text = @"异常备注";
    [self.remarkLabel1 setTitle:@"异常备注" forState:UIControlStateNormal];
    if ([line.exceptionState isEqualToString:@"1"]) {
        if (line.exceptionRemark) {
            [self.remarkLabel1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        }
        else
            [self.remarkLabel1 setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
        
    }
    else if([line.exceptionState isEqualToString:@"0"]){
        if (line.exceptionRemark) {
            [self.remarkLabel1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        }
        else
            [self.remarkLabel1 setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    }
    if ([line.exceptionRemark isEqualToString:@"请在此处输入"]) {
        [self.remarkLabel1 setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    }
}
-(void)setLineF:(LineDetail *)line{
    //        self.taskLabel.text = @"巡逻任务";
    self.remarkLabel.text = @"异常备注";
    [self.remarkLabel1 setTitle:@"异常备注" forState:UIControlStateNormal];
    if ([line.exceptionState isEqualToString:@"1"]) {
        if (![line.exceptionRemark isEqualToString:@""]) {
            [self.remarkLabel1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        }
        else
            [self.remarkLabel1 setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        
    }
    else if([line.exceptionState isEqualToString:@"0"]){
        if (![line.exceptionRemark isEqualToString:@""]) {
            [self.remarkLabel1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        }
        else
            [self.remarkLabel1 setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        
    }
    if ([line.exceptionRemark isEqualToString:@"请在此处输入"]) {
        [self.remarkLabel1 setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    }
    
}
-(void)setModel:(RouteModel *)model{
    _model = model;
    //        self.taskLabel.text = @"巡逻任务";
    self.remarkLabel.text = @"异常备注";
    [self.remarkLabel1 setTitle:@"异常备注" forState:UIControlStateNormal];
    if (model.ID==1) {
        [self.remarkLabel1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    }
    if (model.ID==2||model.ID==3||model.ID==4) {
        [self.remarkLabel1 setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    }
    
    //    self.tagLabel.text = _model.Tag;
    //    self.timeLabel.text = [XMTool  timeIntervalFromLastTime:_model.UpdateTime];
    //
    //    self.souceLabel.text = _model.Souce;
    //    if ([_model.Tag isEqualToString:@"热门"]) {
    //        self.tagLabel.hidden = NO;
    //
    //        self.tagLabel.backgroundColor = [UIColor xm_colorFromRGB:0xff0000 alpha:0.04];
    //        self.tagLabel.textColor = [UIColor xm_colorFromRGB:0xFF6666];
    //    }else if ([_model.Tag isEqualToString:@"推荐"]){
    //        self.tagLabel.hidden = NO;
    //
    //        self.tagLabel.backgroundColor = [UIColor xm_colorFromRGB:0x212832 alpha:0.04];
    //        self.tagLabel.textColor = [UIColor xm_colorFromRGB:0x1B88EE];
    //    }else{
    //        self.tagLabel.hidden = YES;
    //    }
}
-(void)layoutSubviews{
    [super layoutSubviews];
    //    [self.taskLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    //        make.left.centerX.mas_equalTo(self);
    //    }];
    [self.remarkLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.right.mas_equalTo(self).offset(-10);
        make.width.equalTo(@85);
        if (IS_IPHONE_5) {
            make.width.equalTo(@55);
            
        }
        //        make.height.equalTo(@30);
        
    }];
    
}
-(void)drawRect:(CGRect)rect{
    [super drawRect:rect];
}

@end
